><

Using Variables



Adobe GoLive features a set of actions that allows you to use variables. You can use variables as an input to other scripted actions, replacing settings you would make in the Inspector.

There are two major uses for variables defined with the Set Variable action:

  • You can use variables as pseudo-constants to specify a fixed value for another action.
  • You can dynamically store object properties in variables at runtime and set a cookie to write them to the viewer's hard disk. This is possible for selected properties of the browser window, such as background color.

  • To use a variable in a page, you must declare it first. After declaring a variable, you may want to initialize it.

    To declare a variable:

    1 Drag the Head Action icon from the Smart tab of the Objects palette into the head section of the page.

    2 In the Action Inspector, choose Declare Variable from the Variables submenu of the Action menu. (In order for Call Action to work, the trigger for the action in the header must be set to OnCall (see Get Form Value).)

    3 Enter a variable name in the Name text box. Make sure that its name is not used by any other JavaScript item in the page, and follows the standard JavaScript naming conventions for variables. Names must consist of alphabetical characters only. Digits, dashes, slashes, and other non-alpha characters are not allowed.

    4 Choose an appropriate data type from the Type menu:

    Boolean Any on/off state in the current page.

    Integer Any integer value in the current page.

    Float Any floating point value in the current page.

    String Any string value in the current page.

    Layer Any floating box in the current page.

    Layer Position Location of a floating box in the current page.

    Image Any image in the current page.

    URL Any URL in the current page.

    Color Any color in the current page.

    Scene Any scene in the current page.

    OnCall Action Any action from the head section of the page whose trigger is set to OnCall (see Get Form Value).

    Function Any function declared in the head section of the page.

    5 Use the Cookie text box to enter the name of the cookie in which you want to store the value of the variable on the viewer's hard disk. You will use the Write Cookie and Read Cookie actions explained later in this section to set the cookie and read its content, respectively.

    To initialize a variable:

    1 Drag the Head Action icon from the Smart tab () of the Objects palette into the head section of the page.

    2 In the Action Inspector, choose Init Variable from the Variables submenu of the Action menu.

    3 Choose the variable you want to initialize from the Variables pop-up menu. (You must have declared your variable for it to appear in the pop-up menu.)

    4 The Value item changes automatically with the type of the variable. Use the appropriate control to supply an initial value:

    Boolean A checkbox (selected is true, deselected is false).

    Integer A text box that accepts whole numbers only.

    Float A text box that accepts numbers with decimal points.

    String A text box that accepts any string of text.

    Layer A pop-up menu showing all floating boxes in the page.

    LayerPos Two x and y text boxes for the position of a floating box and a Get button that reads the current position.

    Image A pop-up menu listing the named images in the current page.

    URL A typical text box, Browse button and Point and Shoot button combination for specifying URLs.

    Color A color field that brings up the Color palette when clicked.

    Scenes A pop-up menu that lists all scenes in the current page.

    OnCall Action A pop-up menu listing all actions from the head section that have their trigger set to OnCall (see Get Form Value).

    Functions A pop-up menu that lists all function declarations from the head section of the current page.


    Using Actions > Using Adobe GoLive actions > Using Variables